package main

import (
	"baikBingo/pkg/Util"
	"baikBingo/routers"
	"net/http"

	"github.com/gin-gonic/gin"
)

/*
|--------------------------------------------------------------------------
| 入口文件
|--------------------------------------------------------------------------
|
| 在此处进行入口的配置
|
*/
func main() {
	//设置服务启动模式
	initMode(Util.Config("env.setting.HTTPMode"))
	//服务初始化
	server := gin.New()
	server.Static("/static", "./public/static")
	server.LoadHTMLGlob("public/index.html")
	server.GET("/", func(c *gin.Context) {
		c.HTML(http.StatusOK, "index.html", gin.H{
			"title": "BaiKBingo",
		})
	})
	//配置路由
	routers.Auth(server)
	routers.API(server)
	//运行服务
	server.Run(Util.Config("env.setting.HTTPPort"))
}

/*
 * 设置服务启动模式
 * val string "debug or release"
 */
func initMode(val string) {
	if val == "debug" {
		gin.SetMode(gin.DebugMode)
	} else {
		gin.SetMode(gin.ReleaseMode)
	}
}
